package com.strawcom.charmring;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;

import com.strawcom.charmring.util.BaseUtil;

/**
 * 
 * @ClassName: BaseFragment
 * @Description:BaseFragment
 * @author liyongqiang
 * @date 2015-3-30 下午11:43:50
 * 
 */
public class BaseFragment extends Fragment {

	protected BaseActivity holderActivity;

	@Override public void onAttach(Activity activity) {
		super.onAttach(activity);
		if (activity instanceof BaseActivity) {
			holderActivity = (BaseActivity) activity;
		}
	}
	
	@Override public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);
		
	}

	public void actionStart(Class<?> target, Object... params) {
		if (holderActivity != null) {
			holderActivity.actionStart(target, BaseUtil.initBundle(params));
		}
	}

	public void actionStart(Class<?> target, Bundle bundle) {
		if (holderActivity != null) {
			holderActivity.actionStart(target, bundle);
		}
	}

	public void showToast(int resId) {
		if (holderActivity != null) {
			holderActivity.showToast(resId);
		}
	}

	public void showToast(String text) {
		if (holderActivity != null) {
			holderActivity.showToast(text);
		}
	}
}
